<html>
  <head>
    <title>pako tests</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
    <script src="../../node_modules/mocha/mocha.js"></script>
    <script>
      mocha.setup('bdd');
      mocha.suite.timeout(30000);
    </script>
    <script>
      function assert(expr, msg) {
        if (!expr) throw new Error(msg || 'failed');
      }
    </script>
    <script>
      function assert(expr, msg) {
        if (!expr) throw new Error(msg || 'failed');
      }
    </script>
    <script src="./pako.js"></script>
    <script src="./test.js"></script>
    <script>
     onload = function(){
        var runner = mocha.run();

        var failedTests = [];
        runner.on('end', function(){
          window.mochaResults = runner.stats;
          window.mochaResults.reports = failedTests;
        });

        runner.on('fail', logFailure);

        function logFailure(test, err){

          var flattenTitles = function(test){
            var titles = [];
            while (test.parent.title){
              titles.push(test.parent.title);
              test = test.parent;
            }
            return titles.reverse();
          };

          failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test) });
        };
      };
    </script>
  </head>
  <body>
    <div id="mocha"></div>
  </body>
</html>

